package com.xmut.base.service.impl;

import com.xmut.base.service.BaseService;
import org.springframework.data.domain.Example;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.jpa.repository.JpaRepository;

import java.io.Serializable;
import java.util.List;

public abstract class BaseServiceImpl<T, ID extends Serializable> implements BaseService<T,ID> {

    private JpaRepository<T,ID> dao;

    public abstract JpaRepository<T, ID> getDao();

    @Override
    public List<T> findAll() {
        return getDao().findAll();
    }

    @Override
    public List<T> findAll(Sort var1) {
        return getDao().findAll();
    }

    @Override
    public Page<T> findAll(Pageable pageable) {
        return getDao().findAll(pageable);
    }

    @Override
    public List<T> findAll(Iterable<ID> var1) {
        return getDao().findAll(var1);
    }

    @Override
    public long count() {
        return getDao().count();
    }

    @Override
    public void delete(ID id) {
        getDao().delete(id);
    }

    @Override
    public void delete(T t) {
        getDao().delete(t);
    }

    @Override
    public void delete(Iterable<? extends T> iterable) {
        getDao().delete(iterable);
    }

    @Override
    public void deleteAll() {
        getDao().deleteAll();
    }

    @Override
    public <S extends T> S save(S s) {
        return getDao().save(s);
    }

    @Override
    public <S extends T> List<S> save(Iterable<S> var1) {
        return getDao().save(var1);
    }

    @Override
    public T findOne(ID id) {
        return  getDao().findOne(id);
    }

    @Override
    public boolean exists(ID id) {
        return getDao().exists(id);
    }

    @Override
    public void flush() {
        getDao().flush();
    }

    @Override
    public <S extends T> S saveAndFlush(S var1) {
        return getDao().saveAndFlush(var1);
    }

    @Override
    public void deleteInBatch(Iterable<T> var1) {
        getDao().deleteInBatch(var1);
    }

    @Override
    public void deleteAllInBatch() {
        getDao().deleteAllInBatch();
    }

    @Override
    public T getOne(ID var1) {
        return getDao().getOne(var1);
    }

    @Override
    public <S extends T> S findOne(Example<S> example) {
        return getDao().findOne(example);
    }

    @Override
    public <S extends T> List<S> findAll(Example<S> var1) {
        return getDao().findAll(var1);
    }

    @Override
    public <S extends T> List<S> findAll(Example<S> var1, Sort var2) {
        return getDao().findAll(var1,var2);
    }

    @Override
    public <S extends T> Page<S> findAll(Example<S> example, Pageable pageable) {
        return getDao().findAll(example, pageable);
    }

    @Override
    public <S extends T> long count(Example<S> example) {
        return getDao().count();
    }

    @Override
    public <S extends T> boolean exists(Example<S> example) {
        return getDao().exists(example);
    }
}
